package com.bkitmobile.kesu.appengine.storingdata.server.entity;

import java.io.Serializable;

import java.util.LinkedList;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.datastore.Text;
@PersistenceCapable
public class Message  {
	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private String sender;
	
	@Persistent
	private List<Text> message;
	
	@Persistent
	private String receiver;
	public Message(String sender,String receiver)
	{
		setKey(KeyFactory.createKey(Message.class.getSimpleName(), sender+"-"+receiver));
		this.sender = sender;
		message = new LinkedList<Text>();
		this.setReceiver(receiver);
	}
	public Message(String sender,String receiver,List<Text> message)
	{
		setKey(KeyFactory.createKey(Message.class.getSimpleName(), sender+"-"+receiver));
		this.sender = sender;
		this.message = message;
		this.setReceiver(receiver);
	}
	public Message(String sender,String receiver,Text message)
	{
		setKey(KeyFactory.createKey(Message.class.getSimpleName(), sender+"-"+receiver));
		this.sender = sender;
		this.message = new LinkedList<Text>();
		this.message.add(message);
		this.setReceiver(receiver);
	}
	public void addMessage(Text message)
	{
		this.message.add(message);
	}
	public void setSender(String sender) {
		this.sender = sender;
	}
	public String getSender() {
		return sender;
	}
	public void setMessage(List<Text> message) {
		this.message = message;
	}
	public List<Text> getMessage() {
		return message;
	}
	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}
	public String getReceiver() {
		return receiver;
	}
	public void setKey(Key key) {
		this.key = key;
	}
	public Key getKey() {
		return key;
	}
	
}
